
#include "atomic_op_namespace.h"

#include <sys/atomic.h>

uint16_t atomic_and_16_nv(volatile uint16_t *addr, uint16_t val);

uint16_t
atomic_and_16_nv(volatile uint16_t *addr, uint16_t val)
{
	uint16_t old, new;

	do {
		old = *addr;
		new = old & val;
	} while (atomic_cas_16(addr, old, new) != old);

	return (new);
}

#undef atomic_and_16_nv
atomic_op_alias(atomic_and_16_nv,_atomic_and_16_nv)
crt_alias(__sync_and_and_fetch_2,_atomic_and_16_nv)
